package com.test16_内部类;

/**
 * 内部接口
 */
public class YootkDemo_02 {

    public static void main(String[] args) {
        IMessage message = new EduMessage();
        message.send("李兴华编程训练营：yootk.ke.qq.com");
    }
}

interface IMessage {
    public void send(String message);

    interface IChannel {    // 通道支持
        public boolean build();
        public void close();
    }
}

class EduMessage implements IMessage {  // 实现了外部接口

    @Override
    public void send(String message) {
        IChannel channel = new InternetChannel();
        if (channel.build()) {
            System.out.println("【消息发送】" + message);
            channel.close();
        }
    }

    class InternetChannel implements IChannel {     // 实现内部接口

        @Override
        public boolean build() {
            System.out.println("【InternetChannel】建立消息发送通道...");
            return true;
        }

        @Override
        public void close() {
            System.out.println("【InternetChannel】关闭消息发送通道...");
        }
    }
}
